package fr.afcepf.atod18.restaurants.dao;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import fr.afcepf.atod18.restaurants.entity.Promotion;
import fr.afcepf.atod18.restaurants.idao.IDaoPromotion;

public class DaoPromotion extends HibernateDaoSupport implements IDaoPromotion {

	@Override
	public void creerPromotion(Promotion promotion) {
		getHibernateTemplate().save(promotion);
	}

	@Override
	public void activerPromotion(Promotion promotion) {
		promotion.setDateDebut(new java.util.Date());
		getHibernateTemplate().update(promotion);
	}

	@Override
	public void desactiverPromotion(Promotion promotion) {
		promotion.setDateFin(new java.util.Date());
		getHibernateTemplate().update(promotion);
	}

	@Override
	public Promotion chercherPromotion(int idPromotion) {
		return getHibernateTemplate().get(Promotion.class, idPromotion);
	}

}
